<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>CellFormat (POI API Documentation)</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="CellFormat (POI API Documentation)";
    }
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!--   -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CellFormat.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/poi/ss/format/CellElapsedFormatter.html" title="class in org.apache.poi.ss.format"><span class="strong">PREV CLASS</span></a></li>
<li><a href="../../../../../org/apache/poi/ss/format/CellFormatCondition.html" title="class in org.apache.poi.ss.format"><span class="strong">NEXT CLASS</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/poi/ss/format/CellFormat.html" target="_top">FRAMES</a></li>
<li><a href="CellFormat.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_top");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>SUMMARY:&nbsp;</li>
<li>NESTED&nbsp;|&nbsp;</li>
<li><a href="#field_summary">FIELD</a>&nbsp;|&nbsp;</li>
<li>CONSTR&nbsp;|&nbsp;</li>
<li><a href="#method_summary">METHOD</a></li>
</ul>
<ul class="subNavList">
<li>DETAIL:&nbsp;</li>
<li><a href="#field_detail">FIELD</a>&nbsp;|&nbsp;</li>
<li>CONSTR&nbsp;|&nbsp;</li>
<li><a href="#method_detail">METHOD</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!--   -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<p class="subTitle">org.apache.poi.ss.format</p>
<h2 title="Class CellFormat" class="title">Class CellFormat</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>org.apache.poi.ss.format.CellFormat</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<br>
<pre>public class <strong>CellFormat</strong>
extends java.lang.Object</pre>
<div class="block">Format a value according to the standard Excel behavior.  This "standard" is
 not explicitly documented by Microsoft, so the behavior is determined by
 experimentation; see the tests.
 <p/>
 An Excel format has up to four parts, separated by semicolons.  Each part
 specifies what to do with particular kinds of values, depending on the number
 of parts given: <dl> <dt>One part (example: <tt>[Green]#.##</tt>) <dd>If the
 value is a number, display according to this one part (example: green text,
 with up to two decimal points). If the value is text, display it as is.
 <dt>Two parts (example: <tt>[Green]#.##;[Red]#.##</tt>) <dd>If the value is a
 positive number or zero, display according to the first part (example: green
 text, with up to two decimal points); if it is a negative number, display
 according to the second part (example: red text, with up to two decimal
 points). If the value is text, display it as is. <dt>Three parts (example:
 <tt>[Green]#.##;[Black]#.##;[Red]#.##</tt>) <dd>If the value is a positive
 number, display according to the first part (example: green text, with up to
 two decimal points); if it is zero, display according to the second part
 (example: black text, with up to two decimal points); if it is a negative
 number, display according to the third part (example: red text, with up to
 two decimal points). If the value is text, display it as is. <dt>Four parts
 (example: <tt>[Green]#.##;[Black]#.##;[Red]#.##;[@]</tt>) <dd>If the value is
 a positive number, display according to the first part (example: green text,
 with up to two decimal points); if it is zero, display according to the
 second part (example: black text, with up to two decimal points); if it is a
 negative number, display according to the third part (example: red text, with
 up to two decimal points). If the value is text, display according to the
 fourth part (example: text in the cell's usual color, with the text value
 surround by brackets). </dl>
 <p/>
 In addition to these, there is a general format that is used when no format
 is specified.  This formatting is presented by the <a href="../../../../../org/apache/poi/ss/format/CellFormat.html#GENERAL_FORMAT"><code>GENERAL_FORMAT</code></a>
 object.
 
 TODO Merge this with <a href="../../../../../org/apache/poi/ss/usermodel/DataFormatter.html" title="class in org.apache.poi.ss.usermodel"><code>DataFormatter</code></a> so we only have one set of
 code for formatting numbers.</div>
<dl><dt><span class="strong">Author:</span></dt>
  <dd>Ken Arnold, Industrious Media LLC</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== FIELD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_summary">
<!--   -->
</a>
<h3>Field Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Field Summary table, listing fields, and an explanation">
<caption><span>Fields</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Field and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format">CellFormat</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#GENERAL_FORMAT">GENERAL_FORMAT</a></strong></code>
<div class="block">Format a value as it would be were no format specified.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!--   -->
</a>
<h3>Method Summary</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#apply(org.apache.poi.ss.usermodel.Cell)">apply</a></strong>(<a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;c)</code>
<div class="block">Fetches the appropriate value from the cell, and returns the result of
 applying it to the appropriate format.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#apply(javax.swing.JLabel, org.apache.poi.ss.usermodel.Cell)">apply</a></strong>(javax.swing.JLabel&nbsp;label,
     <a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;c)</code>
<div class="block">Fetches the appropriate value from the cell, and uses the result, setting
 the text and color of a label before returning the result.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#apply(javax.swing.JLabel, java.lang.Object)">apply</a></strong>(javax.swing.JLabel&nbsp;label,
     java.lang.Object&nbsp;value)</code>
<div class="block">Uses the result of applying this format to the value, setting the text
 and color of a label before returning the result.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#apply(java.lang.Object)">apply</a></strong>(java.lang.Object&nbsp;value)</code>
<div class="block">Returns the result of applying the format to the given value.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>boolean</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#equals(java.lang.Object)">equals</a></strong>(java.lang.Object&nbsp;obj)</code>
<div class="block">Returns <tt>true</tt> if the other object is a <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format"><code>CellFormat</code></a> object
 with the same format.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format">CellFormat</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#getInstance(java.lang.String)">getInstance</a></strong>(java.lang.String&nbsp;format)</code>
<div class="block">Returns a <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format"><code>CellFormat</code></a> that applies the given format.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#hashCode()">hashCode</a></strong>()</code>
<div class="block">Returns a hash code for the format.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>static int</code></td>
<td class="colLast"><code><strong><a href="../../../../../org/apache/poi/ss/format/CellFormat.html#ultimateType(org.apache.poi.ss.usermodel.Cell)">ultimateType</a></strong>(<a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;cell)</code>
<div class="block">Returns the ultimate cell type, following the results of formulas.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!--   -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ FIELD DETAIL =========== -->
<ul class="blockList">
<li class="blockList"><a name="field_detail">
<!--   -->
</a>
<h3>Field Detail</h3>
<a name="GENERAL_FORMAT">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>GENERAL_FORMAT</h4>
<pre>public static final&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format">CellFormat</a> GENERAL_FORMAT</pre>
<div class="block">Format a value as it would be were no format specified.  This is also
 used when the format specified is <tt>General</tt>.</div>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!--   -->
</a>
<h3>Method Detail</h3>
<a name="getInstance(java.lang.String)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getInstance</h4>
<pre>public static&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format">CellFormat</a>&nbsp;getInstance(java.lang.String&nbsp;format)</pre>
<div class="block">Returns a <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format"><code>CellFormat</code></a> that applies the given format.  Two calls
 with the same format may or may not return the same object.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>format</code> - The format.</dd>
<dt><span class="strong">Returns:</span></dt><dd>A <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format"><code>CellFormat</code></a> that applies the given format.</dd></dl>
</li>
</ul>
<a name="apply(java.lang.Object)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>apply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a>&nbsp;apply(java.lang.Object&nbsp;value)</pre>
<div class="block">Returns the result of applying the format to the given value.  If the
 value is a number (a type of <code>Number</code> object), the correct number
 format type is chosen; otherwise it is considered a text object.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>value</code> - The value</dd>
<dt><span class="strong">Returns:</span></dt><dd>The result, in a <a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format"><code>CellFormatResult</code></a>.</dd></dl>
</li>
</ul>
<a name="apply(org.apache.poi.ss.usermodel.Cell)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>apply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a>&nbsp;apply(<a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;c)</pre>
<div class="block">Fetches the appropriate value from the cell, and returns the result of
 applying it to the appropriate format.  For formula cells, the computed
 value is what is used.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>c</code> - The cell.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The result, in a <a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format"><code>CellFormatResult</code></a>.</dd></dl>
</li>
</ul>
<a name="apply(javax.swing.JLabel, java.lang.Object)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>apply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a>&nbsp;apply(javax.swing.JLabel&nbsp;label,
                     java.lang.Object&nbsp;value)</pre>
<div class="block">Uses the result of applying this format to the value, setting the text
 and color of a label before returning the result.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>label</code> - The label to apply to.</dd><dd><code>value</code> - The value to process.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The result, in a <a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format"><code>CellFormatResult</code></a>.</dd></dl>
</li>
</ul>
<a name="apply(javax.swing.JLabel, org.apache.poi.ss.usermodel.Cell)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>apply</h4>
<pre>public&nbsp;<a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format">CellFormatResult</a>&nbsp;apply(javax.swing.JLabel&nbsp;label,
                     <a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;c)</pre>
<div class="block">Fetches the appropriate value from the cell, and uses the result, setting
 the text and color of a label before returning the result.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>label</code> - The label to apply to.</dd><dd><code>c</code> - The cell.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The result, in a <a href="../../../../../org/apache/poi/ss/format/CellFormatResult.html" title="class in org.apache.poi.ss.format"><code>CellFormatResult</code></a>.</dd></dl>
</li>
</ul>
<a name="ultimateType(org.apache.poi.ss.usermodel.Cell)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>ultimateType</h4>
<pre>public static&nbsp;int&nbsp;ultimateType(<a href="../../../../../org/apache/poi/ss/usermodel/Cell.html" title="interface in org.apache.poi.ss.usermodel">Cell</a>&nbsp;cell)</pre>
<div class="block">Returns the ultimate cell type, following the results of formulas.  If
 the cell is a <a href="../../../../../org/apache/poi/ss/usermodel/Cell.html#CELL_TYPE_FORMULA"><code>Cell.CELL_TYPE_FORMULA</code></a>, this returns the result of
 <a href="../../../../../org/apache/poi/ss/usermodel/Cell.html#getCachedFormulaResultType()"><code>Cell.getCachedFormulaResultType()</code></a>.  Otherwise this returns the
 result of <a href="../../../../../org/apache/poi/ss/usermodel/Cell.html#getCellType()"><code>Cell.getCellType()</code></a>.</div>
<dl><dt><span class="strong">Parameters:</span></dt><dd><code>cell</code> - The cell.</dd>
<dt><span class="strong">Returns:</span></dt><dd>The ultimate type of this cell.</dd></dl>
</li>
</ul>
<a name="equals(java.lang.Object)">
<!--   -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>equals</h4>
<pre>public&nbsp;boolean&nbsp;equals(java.lang.Object&nbsp;obj)</pre>
<div class="block">Returns <tt>true</tt> if the other object is a <a href="../../../../../org/apache/poi/ss/format/CellFormat.html" title="class in org.apache.poi.ss.format"><code>CellFormat</code></a> object
 with the same format.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>equals</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Parameters:</span></dt><dd><code>obj</code> - The other object.</dd>
<dt><span class="strong">Returns:</span></dt><dd><tt>true</tt> if the two objects are equal.</dd></dl>
</li>
</ul>
<a name="hashCode()">
<!--   -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>hashCode</h4>
<pre>public&nbsp;int&nbsp;hashCode()</pre>
<div class="block">Returns a hash code for the format.</div>
<dl>
<dt><strong>Overrides:</strong></dt>
<dd><code>hashCode</code>&nbsp;in class&nbsp;<code>java.lang.Object</code></dd>
<dt><span class="strong">Returns:</span></dt><dd>A hash code for the format.</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!--   -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!--   -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/CellFormat.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../org/apache/poi/ss/format/CellElapsedFormatter.html" title="class in org.apache.poi.ss.format"><span class="strong">PREV CLASS</span></a></li>
<li><a href="../../../../../org/apache/poi/ss/format/CellFormatCondition.html" title="class in org.apache.poi.ss.format"><span class="strong">NEXT CLASS</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?org/apache/poi/ss/format/CellFormat.html" target="_top">FRAMES</a></li>
<li><a href="CellFormat.html" target="_top">NO FRAMES</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
  allClassesLink = document.getElementById("allclasses_navbar_bottom");
  if(window==top) {
    allClassesLink.style.display = "block";
  }
  else {
    allClassesLink.style.display = "none";
  }
  //-->
</script>
</div>
<div>
<ul class="subNavList">
<li>SUMMARY:&nbsp;</li>
<li>NESTED&nbsp;|&nbsp;</li>
<li><a href="#field_summary">FIELD</a>&nbsp;|&nbsp;</li>
<li>CONSTR&nbsp;|&nbsp;</li>
<li><a href="#method_summary">METHOD</a></li>
</ul>
<ul class="subNavList">
<li>DETAIL:&nbsp;</li>
<li><a href="#field_detail">FIELD</a>&nbsp;|&nbsp;</li>
<li>CONSTR&nbsp;|&nbsp;</li>
<li><a href="#method_detail">METHOD</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!--   -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>
                <i>Copyright 2014 The Apache Software Foundation or
        its licensors, as applicable.</i>
            </small></p>
</body>
</html>
